package org.example;

import java.lang.reflect.InvocationTargetException;

/**
 * @author TonySong
 * @date 2025/7/30 0030
 * @time 16:08
 */
public class FlyFactory {

    public static IFly createFly(String className) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        IFly fly=null;
        Class<?> c = Class.forName(className);
        Object obj = c.getConstructor().newInstance();

        if(obj instanceof IFly) {
            fly = (IFly) obj;
        }
        return  fly;
    }
}
